@extends('admin::layouts.master')

@section('title', __('seller::withdraw.title'))

@section('content')
@if ($errors->has('error'))
<x-seller-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
@endif

@if (session()->has('success'))
<x-seller-alert type="success" msg="{{ session('success') }}" class="mt-4" />
@endif

<div class="card">
  <div class="card-body h-min-600">
    {{-- {{ dd($withdraws) }} --}}
    <div class="table-push">
      @if (count($withdraws))
      <table class="table">
        <thead>
          <tr>
            <th>ID</th>
            <th>{{ __('MultiSeller::common.shop') }}</th>
            <th>{{ __('seller::withdraw.withdraw_amount') }}</th>
            <th>{{ __('common.status') }}</th>
            <th>{{ __('seller::withdraw.paid_at') }}</th>
            <th>{{ __('MultiSeller::common.withdraw_banks') }}</th>
            <th>{{ __('MultiSeller::common.bank_account') }}</th>
            <th>{{ __('common.created_at') }}</th>
            <th>{{ __('MultiSeller::common.comment') }}</th>
            <th>{{ __('common.action') }}</th>
          </tr>
        </thead>
        <tbody>
          @foreach ($withdraws as $item)
          <tr>
            <td>{{ $item['id'] }}</td>
            <td>{{ $item['seller']['store_name'] ?? '' }}</td>
            <td>{{ $item['amount'] }}</td>
            <td class="{{ $item['status'] ? 'text-success' : 'text-secondary' }}">
              {{ $item['status'] ? __('seller::withdraw.text_processed') : __('seller::withdraw.text_Pending') }}
            </td>
            <td>{{ $item['paid_at'] }}</td>
            <td>{{ $item['bank'] }}</td>
            <td>{{ $item['bank_account'] }}({{ $item['bank_name'] }})</td>
            <td>{{ $item['created_at'] }}</td>
            <td>{{ $item['description'] }}</td>
            <td>
              @if (!$item['status'])
                <a class="btn btn-sm btn-outline-secondary" href="{{ admin_route('withdraws.edit', $item['id']) }}">{{  __('MultiSeller::common.deal_with')  }}</a>
              @endif
            </td>
          </tr>
          @endforeach
        </tbody>
      </table>
      @else
      <div>
        <x-seller-no-data />
      </div>
      @endif
    </div>
  </div>
</div>
@endsection
